\rcube_imap_generic

PHP based wrapper class to connect to an IMAP server

Summary

Methods
Properties
Constants
getCapability()
clearCapability()
getHierarchyDelimiter()
getNamespace()
connect()
connected()
closeConnection()
select()
status()
expunge()
close()
subscribe()
unsubscribe()
createFolder()
renameFolder()
deleteFolder()
clearFolder()
listMailboxes()
listSubscribed()
countMessages()
countRecent()
countUnseen()
id()
enable()
sort()
thread()
search()
index()
fetchHeaderIndex()
UID2ID()
ID2UID()
flag()
unflag()
copy()
move()
fetch()
fetchHeaders()
fetchHeader()
sortHeaders()
fetchMIMEHeaders()
fetchPartHeader()
handlePartBody()
append()
appendFromFile()
getQuota()
setACL()
deleteACL()
getACL()
listRights()
myRights()
setMetadata()
deleteMetadata()
getMetadata()
setAnnotation()
deleteAnnotation()
getAnnotation()
getStructure()
getStructurePartData()
getStructurePartArray()
nextTag()
execute()
tokenizeResponse()
compressMessageSet()
uncompressMessageSet()
escape()
setDebug()
$error
$errornum
$result
$resultcode
$selected
$data
$flags
ERROR_OK
ERROR_NO
ERROR_BAD
ERROR_BYE
ERROR_UNKNOWN
ERROR_COMMAND
ERROR_READONLY
COMMAND_NORESPONSE
COMMAND_CAPABILITY
COMMAND_LASTLINE
COMMAND_ANONYMIZED
DEBUG_LINE_LENGTH
putLine()
putLineC()
readLine()
readFullLine()
multLine()
readBytes()
readReply()
parseResult()
eof()
closeSocket()
setError()
startsWith()
hasCapability()
authenticate()
login()
_connect()
set_prefs()
_listMailboxes()
modFlag()
r_implode()
clear_status_cache()
clear_mailbox_cache()
flagsToStr()
parseCapability()
debug()
$fp
$host
$user
$cmd_tag
$cmd_num
$resourceid
$extensions_enabled
$prefs
$logged
$capability
$capability_read
$debug
$debug_handler
N/A
No private methods found
No private properties found
N/A

Constants

ERROR_OK

ERROR_OK = 0

ERROR_NO

ERROR_NO = -1

ERROR_BAD

ERROR_BAD = -2

ERROR_BYE

ERROR_BYE = -3

ERROR_UNKNOWN

ERROR_UNKNOWN = -4

ERROR_COMMAND

ERROR_COMMAND = -5

ERROR_READONLY

ERROR_READONLY = -6

COMMAND_NORESPONSE

COMMAND_NORESPONSE = 1

COMMAND_CAPABILITY

COMMAND_CAPABILITY = 2

COMMAND_LASTLINE

COMMAND_LASTLINE = 4

COMMAND_ANONYMIZED

COMMAND_ANONYMIZED = 8

DEBUG_LINE_LENGTH

DEBUG_LINE_LENGTH = 4098

Properties

$error

$error

$errornum

$errornum

$result

$result

$resultcode

$resultcode

$selected

$selected

$data

$data

$flags

$flags

$fp

$fp

$host

$host

$user

$user

$cmd_tag

$cmd_tag

$cmd_num

$cmd_num

$resourceid

$resourceid

$extensions_enabled

$extensions_enabled

$prefs

$prefs

$logged

$logged

$capability

$capability

$capability_read

$capability_read

$debug

$debug

$debug_handler

$debug_handler

Methods

getCapability()

getCapability(string  $name) : mixed

Capabilities checker

Parameters

string $name

Capability name

Returns

mixed —

Capability values array for key=value pairs, true/false for others

clearCapability()

clearCapability() : mixed

Clears detected server capabilities

Returns

mixed —

getHierarchyDelimiter()

getHierarchyDelimiter() : string

Detects hierarchy delimiter

Returns

string —

The delimiter

getNamespace()

getNamespace() : array

NAMESPACE handler (RFC 2342)

Returns

array —

Namespace data hash (personal, other, shared)

connect()

connect(string  $host, string  $user, string  $password, array  $options = []) : bool

Connects to IMAP server and authenticates.

Parameters

string $host

Server hostname or IP

string $user

User name

string $password

Password

array $options

Connection and class options

Returns

bool —

True on success, False on failure

connected()

connected() : bool

Checks connection status

Returns

bool —

True if connection is active and user is logged in, False otherwise.

closeConnection()

closeConnection() : mixed

Closes connection with logout.

Returns

mixed —

select()

select(string  $mailbox, array  $qresync_data = null) : bool

Executes SELECT command (if mailbox is already not in selected state)

Parameters

string $mailbox

Mailbox name

array $qresync_data

QRESYNC data (RFC5162)

Returns

bool —

True on success, false on error

status()

status(string  $mailbox, array  $items = []) : array

Executes STATUS command

Parameters

string $mailbox

Mailbox name

array $items

Additional requested item names. By default MESSAGES and UNSEEN are requested. Other defined in RFC3501: UIDNEXT, UIDVALIDITY, RECENT

Returns

array —

Status item-value hash

expunge()

expunge(string  $mailbox, string|array  $messages = null) : bool

Executes EXPUNGE command

Parameters

string $mailbox

Mailbox name

string|array $messages

Message UIDs to expunge

Returns

bool —

True on success, False on error

close()

close() : bool

Executes CLOSE command

Returns

bool —

True on success, False on error

subscribe()

subscribe(string  $mailbox) : bool

Folder subscription (SUBSCRIBE)

Parameters

string $mailbox

Mailbox name

Returns

bool —

True on success, False on error

unsubscribe()

unsubscribe(string  $mailbox) : bool

Folder unsubscription (UNSUBSCRIBE)

Parameters

string $mailbox

Mailbox name

Returns

bool —

True on success, False on error

createFolder()

createFolder(string  $mailbox, array  $types = null) : bool

Folder creation (CREATE)

Parameters

string $mailbox

Mailbox name

array $types

Optional folder types (RFC 6154)

Returns

bool —

True on success, False on error

renameFolder()

renameFolder(mixed  $from, mixed  $to) : bool

Folder renaming (RENAME)

Parameters

mixed $from
mixed $to

Returns

bool —

True on success, False on error

deleteFolder()

deleteFolder(string  $mailbox) : bool

Executes DELETE command

Parameters

string $mailbox

Mailbox name

Returns

bool —

True on success, False on error

clearFolder()

clearFolder(string  $mailbox) : bool

Removes all messages in a folder

Parameters

string $mailbox

Mailbox name

Returns

bool —

True on success, False on error

listMailboxes()

listMailboxes(string  $ref, string  $mailbox, array  $return_opts = [], array  $select_opts = []) : array|bool

Returns list of mailboxes

Parameters

string $ref

Reference name

string $mailbox

Mailbox name

array $return_opts

(see self::_listMailboxes)

array $select_opts

(see self::_listMailboxes)

Returns

array|bool —

List of mailboxes or hash of options if STATUS/MYRIGHTS response is requested, False on error.

listSubscribed()

listSubscribed(string  $ref, string  $mailbox, array  $return_opts = []) : array|bool

Returns list of subscribed mailboxes

Parameters

string $ref

Reference name

string $mailbox

Mailbox name

array $return_opts

(see self::_listMailboxes)

Returns

array|bool —

List of mailboxes or hash of options if STATUS/MYRIGHTS response is requested, False on error.

countMessages()

countMessages(string  $mailbox) : int

Returns count of all messages in a folder

Parameters

string $mailbox

Mailbox name

Returns

int —

Number of messages, False on error

countRecent()

countRecent(string  $mailbox) : int

Returns count of messages with \Recent flag in a folder

Parameters

string $mailbox

Mailbox name

Returns

int —

Number of messages, False on error

countUnseen()

countUnseen(string  $mailbox) : int

Returns count of messages without \Seen flag in a specified folder

Parameters

string $mailbox

Mailbox name

Returns

int —

Number of messages, False on error

id()

id(array  $items = []) : array|false

Executes ID command (RFC2971)

Parameters

array $items

Client identification information key/value hash

Returns

array|false —

Server identification information key/value hash, False on error

enable()

enable(mixed  $extension) : array|bool

Executes ENABLE command (RFC5161)

Parameters

mixed $extension

Extension name to enable (or array of names)

Returns

array|bool —

List of enabled extensions, False on error

sort()

sort(string  $mailbox, string  $field = 'ARRIVAL', string  $criteria = '', bool  $return_uid = false, string  $encoding = 'US-ASCII') : \rcube_result_index

Executes SORT command

Parameters

string $mailbox

Mailbox name

string $field

Field to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)

string $criteria

Searching criteria

bool $return_uid

Enables UID SORT usage

string $encoding

Character set

Returns

\rcube_result_index —

Response data

thread()

thread(string  $mailbox, string  $algorithm = 'REFERENCES', string  $criteria = '', bool  $return_uid = false, string  $encoding = 'US-ASCII') : \rcube_result_thread

Executes THREAD command

Parameters

string $mailbox

Mailbox name

string $algorithm

Threading algorithm (ORDEREDSUBJECT, REFERENCES, REFS)

string $criteria

Searching criteria

bool $return_uid

Enables UIDs in result instead of sequence numbers

string $encoding

Character set

Returns

\rcube_result_thread —

Thread data

search()

search(string  $mailbox, string  $criteria, bool  $return_uid = false, array  $items = []) : \rcube_result_index

Executes SEARCH command

Parameters

string $mailbox

Mailbox name

string $criteria

Searching criteria

bool $return_uid

Enable UID in result instead of sequence ID

array $items

Return items (MIN, MAX, COUNT, ALL)

Returns

\rcube_result_index —

Result data

index()

index(string  $mailbox, string|array  $message_set, string  $index_field = '', bool  $skip_deleted = true, bool  $uidfetch = false, bool  $return_uid = false) : \rcube_result_index

Simulates SORT command by using FETCH and sorting.

Parameters

string $mailbox

Mailbox name

string|array $message_set

Searching criteria (list of messages to return)

string $index_field

Field to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)

bool $skip_deleted

Makes that DELETED messages will be skipped

bool $uidfetch

Enables UID FETCH usage

bool $return_uid

Enables returning UIDs instead of IDs

Returns

\rcube_result_index —

Response data

fetchHeaderIndex()

fetchHeaderIndex(string  $mailbox, string|array  $message_set, string  $index_field = '', bool  $skip_deleted = true, bool  $uidfetch = false, bool  $return_uid = false) : array|bool

Fetches specified header/data value for a set of messages.

Parameters

string $mailbox

Mailbox name

string|array $message_set

Searching criteria (list of messages to return)

string $index_field

Field to sort by (ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, TO)

bool $skip_deleted

Makes that DELETED messages will be skipped

bool $uidfetch

Enables UID FETCH usage

bool $return_uid

Enables returning UIDs instead of IDs

Returns

array|bool —

List of header values or False on failure

UID2ID()

UID2ID(string  $mailbox, int  $uid) : int

Returns message sequence identifier

Parameters

string $mailbox

Mailbox name

int $uid

Message unique identifier (UID)

Returns

int —

Message sequence identifier

ID2UID()

ID2UID(string  $mailbox, mixed  $id) : int

Returns message unique identifier (UID)

Parameters

string $mailbox

Mailbox name

mixed $id

Returns

int —

Message unique identifier

flag()

flag(string  $mailbox, string|array  $messages, string  $flag) : bool

Sets flag of the message(s)

Parameters

string $mailbox

Mailbox name

string|array $messages

Message UID(s)

string $flag

Flag name

Returns

bool —

True on success, False on failure

unflag()

unflag(string  $mailbox, string|array  $messages, string  $flag) : bool

Unsets flag of the message(s)

Parameters

string $mailbox

Mailbox name

string|array $messages

Message UID(s)

string $flag

Flag name

Returns

bool —

True on success, False on failure

copy()

copy(string|array  $messages, string  $from, string  $to) : bool

Copies message(s) from one folder to another

Parameters

string|array $messages

Message UID(s)

string $from

Mailbox name

string $to

Destination mailbox name

Returns

bool —

True on success, False on failure

move()

move(string|array  $messages, string  $from, string  $to) : bool

Moves message(s) from one folder to another.

Parameters

string|array $messages

Message UID(s)

string $from

Mailbox name

string $to

Destination mailbox name

Returns

bool —

True on success, False on failure

fetch()

fetch(string  $mailbox, mixed  $message_set, bool  $is_uid = false, array  $query_items = [], string  $mod_seq = null, bool  $vanished = false) : array

FETCH command (RFC3501)

Parameters

string $mailbox

Mailbox name

mixed $message_set

Message(s) sequence identifier(s) or UID(s)

bool $is_uid

True if $message_set contains UIDs

array $query_items

FETCH command data items

string $mod_seq

Modification sequence for CHANGEDSINCE (RFC4551) query

bool $vanished

Enables VANISHED parameter (RFC5162) for CHANGEDSINCE query

Returns

array —

List of rcube_message_header elements, False on error

fetchHeaders()

fetchHeaders(string  $mailbox, mixed  $message_set, bool  $is_uid = false, bool  $bodystr = false, array  $add_headers = []) : bool|array

Returns message(s) data (flags, headers, etc.)

Parameters

string $mailbox

Mailbox name

mixed $message_set

Message(s) sequence identifier(s) or UID(s)

bool $is_uid

True if $message_set contains UIDs

bool $bodystr

Enable to add BODYSTRUCTURE data to the result

array $add_headers

List of additional headers

Returns

bool|array —

List of rcube_message_header elements, False on error

fetchHeader()

fetchHeader(string  $mailbox, int  $id, bool  $is_uid = false, bool  $bodystr = false, array  $add_headers = []) : bool|\rcube_message_header

Returns message data (flags, headers, etc.)

Parameters

string $mailbox

Mailbox name

int $id

Message sequence identifier or UID

bool $is_uid

True if $id is an UID

bool $bodystr

Enable to add BODYSTRUCTURE data to the result

array $add_headers

List of additional headers

Returns

bool|\rcube_message_header —

Message data, False on error

sortHeaders()

sortHeaders(array  $messages, string  $field, string  $order = 'ASC') : array

Sort messages by specified header field

Parameters

array $messages

Array of rcube_message_header objects

string $field

Name of the property to sort by

string $order

Sorting order (ASC|DESC)

Returns

array —

Sorted input array

fetchMIMEHeaders()

fetchMIMEHeaders(string  $mailbox, int  $uid, array  $parts, bool  $mime = true) : array|bool

Fetch MIME headers of specified message parts

Parameters

string $mailbox

Mailbox name

int $uid

Message UID

array $parts

Message part identifiers

bool $mime

Use MIME instead of HEADER

Returns

array|bool —

Array containing headers string for each specified body False on failure.

fetchPartHeader()

fetchPartHeader(mixed  $mailbox, mixed  $id, mixed  $is_uid = false, mixed  $part = null) : mixed

Fetches message part header

Parameters

mixed $mailbox
mixed $id
mixed $is_uid
mixed $part

Returns

mixed —

handlePartBody()

handlePartBody(mixed  $mailbox, mixed  $id, mixed  $is_uid = false, mixed  $part = '', mixed  $encoding = null, mixed  $print = null, mixed  $file = null, mixed  $formatted = false, mixed  $max_bytes) : mixed

Fetches body of the specified message part

Parameters

mixed $mailbox
mixed $id
mixed $is_uid
mixed $part
mixed $encoding
mixed $print
mixed $file
mixed $formatted
mixed $max_bytes

Returns

mixed —

append()

append(string  $mailbox, string|array  $message, array  $flags = [], string  $date = null, bool  $binary = false) : string|bool

Handler for IMAP APPEND command

Parameters

string $mailbox

Mailbox name

string|array $message

The message source string or array (of strings and file pointers)

array $flags

Message flags

string $date

Message internal date

bool $binary

Enable BINARY append (RFC3516)

Returns

string|bool —

On success APPENDUID response (if available) or True, False on failure

appendFromFile()

appendFromFile(string  $mailbox, string  $path, string  $headers = null, array  $flags = [], string  $date = null, bool  $binary = false) : string|bool

Handler for IMAP APPEND command.

Parameters

string $mailbox

Mailbox name

string $path

Path to the file with message body

string $headers

Message headers

array $flags

Message flags

string $date

Message internal date

bool $binary

Enable BINARY append (RFC3516)

Returns

string|bool —

On success APPENDUID response (if available) or True, False on failure

getQuota()

getQuota(string  $mailbox = null) : array

Returns QUOTA information

Parameters

string $mailbox

Mailbox name

Returns

array —

Quota information

setACL()

setACL(string  $mailbox, string  $user, mixed  $acl) : bool

Send the SETACL command (RFC4314)

Parameters

string $mailbox

Mailbox name

string $user

User name

mixed $acl

ACL string or array

Returns

bool —

True on success, False on failure

deleteACL()

deleteACL(string  $mailbox, string  $user) : bool

Send the DELETEACL command (RFC4314)

Parameters

string $mailbox

Mailbox name

string $user

User name

Returns

bool —

True on success, False on failure

getACL()

getACL(string  $mailbox) : array

Send the GETACL command (RFC4314)

Parameters

string $mailbox

Mailbox name

Returns

array —

User-rights array on success, NULL on error

listRights()

listRights(string  $mailbox, string  $user) : array

Send the LISTRIGHTS command (RFC4314)

Parameters

string $mailbox

Mailbox name

string $user

User name

Returns

array —

List of user rights

myRights()

myRights(string  $mailbox) : array

Send the MYRIGHTS command (RFC4314)

Parameters

string $mailbox

Mailbox name

Returns

array —

MYRIGHTS response on success, NULL on error

setMetadata()

setMetadata(string  $mailbox, array  $entries) : bool

Send the SETMETADATA command (RFC5464)

Parameters

string $mailbox

Mailbox name

array $entries

Entry-value array (use NULL value as NIL)

Returns

bool —

True on success, False on failure

deleteMetadata()

deleteMetadata(string  $mailbox, array  $entries) : bool

Send the SETMETADATA command with NIL values (RFC5464)

Parameters

string $mailbox

Mailbox name

array $entries

Entry names array

Returns

bool —

True on success, False on failure

getMetadata()

getMetadata(string  $mailbox, array  $entries, array  $options = []) : array

Send the GETMETADATA command (RFC5464)

Parameters

string $mailbox

Mailbox name

array $entries

Entries

array $options

Command options (with MAXSIZE and DEPTH keys)

Returns

array —

GETMETADATA result on success, NULL on error

setAnnotation()

setAnnotation(string  $mailbox, array  $data) : bool

Send the SETANNOTATION command (draft-daboo-imap-annotatemore)

Parameters

string $mailbox

Mailbox name

array $data

Data array where each item is an array with three elements: entry name, attribute name, value

Returns

bool —

True on success, False on failure

deleteAnnotation()

deleteAnnotation(string  $mailbox, array  $data) : bool

Send the SETANNOTATION command with NIL values (draft-daboo-imap-annotatemore)

Parameters

string $mailbox

Mailbox name

array $data

Data array where each item is an array with two elements: entry name and attribute name

Returns

bool —

True on success, False on failure

getAnnotation()

getAnnotation(string  $mailbox, array  $entries, array  $attribs) : array

Send the GETANNOTATION command (draft-daboo-imap-annotatemore)

Parameters

string $mailbox

Mailbox name

array $entries

Entries names

array $attribs

Attribs names

Returns

array —

Annotations result on success, NULL on error

getStructure()

getStructure(string  $mailbox, int  $id, bool  $is_uid = false) : array|bool

Returns BODYSTRUCTURE for the specified message.

Parameters

string $mailbox

Folder name

int $id

Message sequence number or UID

bool $is_uid

True if $id is an UID

Returns

array|bool —

Body structure array or False on error.

getStructurePartData()

getStructurePartData(array  $structure, string  $part) : array

Returns data of a message part according to specified structure.

Parameters

array $structure

Message structure (getStructure() result)

string $part

Message part identifier

Returns

array —

Part data as hash array (type, encoding, charset, size)

getStructurePartArray()

getStructurePartArray(mixed  $a, mixed  $part) : mixed

Parameters

mixed $a
mixed $part

Returns

mixed —

nextTag()

nextTag() : string

Creates next command identifier (tag)

Returns

string —

Command identifier

execute()

execute(string  $command, array  $arguments = [], int  $options, string  $filter = null) : mixed

Sends IMAP command and parses result

Parameters

string $command

IMAP command

array $arguments

Command arguments

int $options

Execution options

string $filter

Line filter (regexp)

Returns

mixed —

Response code or list of response code and data

tokenizeResponse()

tokenizeResponse(string  $str, int  $num) : mixed

Splits IMAP response into string tokens

Parameters

string $str

The IMAP's server response

int $num

Number of tokens to return

Returns

mixed —

Tokens array or string if $num=1

compressMessageSet()

compressMessageSet(array  $messages, bool  $force = false) : string

Converts message identifiers array into sequence-set syntax

Parameters

array $messages

Message identifiers

bool $force

Forces compression of any size

Returns

string —

Compressed sequence-set

uncompressMessageSet()

uncompressMessageSet(string  $messages) : array

Converts message sequence-set into array

Parameters

string $messages

Message identifiers

Returns

array —

List of message identifiers

escape()

escape(string  $string, bool  $force_quotes = false) : string

Escapes a string when it contains special characters (RFC3501)

Parameters

string $string

IMAP string

bool $force_quotes

Forces string quoting (for atoms)

Returns

string —

String atom, quoted-string or string literal

setDebug()

setDebug(bool  $debug, callable  $handler = null) : mixed

Set the value of the debugging flag.

Parameters

bool $debug

New value for the debugging flag.

callable $handler

Logging handler function

Returns

mixed —

putLine()

putLine(string  $string, bool  $endln = true, bool  $anonymized = false) : mixed

Send simple (one line) command to the connection stream

Parameters

string $string

Command string

bool $endln

True if CRLF need to be added at the end of command

bool $anonymized

Don't write the given data to log but a placeholder

Returns

mixed —

putLineC()

putLineC(string  $string, bool  $endln = true, bool  $anonymized = false) : int|bool

Send command to the connection stream with Command Continuation Requests (RFC3501 7.5) and LITERAL+ (RFC2088) and LITERAL- (RFC7888) support.

Parameters

string $string

Command string

bool $endln

True if CRLF need to be added at the end of command

bool $anonymized

Don't write the given data to log but a placeholder

Returns

int|bool —

Number of bytes sent, False on error

readLine()

readLine(int  $size = 1024) : string

Reads line from the connection stream

Parameters

int $size

Buffer size

Returns

string —

Line of text response

readFullLine()

readFullLine(int  $size = 1024) : string

Reads a line of data from the connection stream including all string continuation literals.

Parameters

int $size

Buffer size

Returns

string —

Line of text response

multLine()

multLine(string  $line, bool  $escape = false) : string

Reads more data from the connection stream when provided data contain string literal

Parameters

string $line

Response text

bool $escape

Enables escaping

Returns

string —

Line of text response

readBytes()

readBytes(int  $bytes) : string

Reads specified number of bytes from the connection stream

Parameters

int $bytes

Number of bytes to get

Returns

string —

Response text

readReply()

readReply(array  $untagged = null) : string

Reads complete response to the IMAP command

Parameters

array $untagged

Will be filled with untagged response lines

Returns

string —

Response text

parseResult()

parseResult(string  $string, string  $err_prefix = '') : int

Response parser.

Parameters

string $string

Response text

string $err_prefix

Error message prefix

Returns

int —

Response status

eof()

eof() : bool

Checks connection stream state.

Returns

bool —

True if connection is closed

closeSocket()

closeSocket() : mixed

Closes connection stream.

Returns

mixed —

setError()

setError(mixed  $code, mixed  $msg = '') : mixed

Error code/message setter.

Parameters

mixed $code
mixed $msg

Returns

mixed —

startsWith()

startsWith(string  $string, string  $match, bool  $error = false, bool  $nonempty = false) : bool

Checks response status.

Checks if command response line starts with specified prefix (or * BYE/BAD)

Parameters

string $string

Response text

string $match

Prefix to match with (case-sensitive)

bool $error

Enables BYE/BAD checking

bool $nonempty

Enables empty response checking

Returns

bool —

True any check is true or connection is closed.

hasCapability()

hasCapability(mixed  $name) : mixed

Capabilities checker

Parameters

mixed $name

Returns

mixed —

authenticate()

authenticate(string  $user, string  $pass, string  $type = 'PLAIN') : resource

DIGEST-MD5/CRAM-MD5/PLAIN Authentication

Parameters

string $user

Username

string $pass

Password

string $type

Authentication type (PLAIN/CRAM-MD5/DIGEST-MD5)

Returns

resource —

Connection resource on success, error code on error

login()

login(string  $user, mixed  $password) : resource

LOGIN Authentication

Parameters

string $user

Username

mixed $password

Returns

resource —

Connection resource on success, error code on error

_connect()

_connect(string  $host) : bool

Connects to IMAP server.

Parameters

string $host

Server hostname or IP

Returns

bool —

True on success, False on failure

set_prefs()

set_prefs(mixed  $prefs) : mixed

Initializes environment

Parameters

mixed $prefs

Returns

mixed —

_listMailboxes()

_listMailboxes(string  $ref, string  $mailbox, bool  $subscribed = false, array  $return_opts = [], array  $select_opts = []) : array|bool

IMAP LIST/LSUB command

Parameters

string $ref

Reference name

string $mailbox

Mailbox name

bool $subscribed

Enables returning subscribed mailboxes only

array $return_opts

List of RETURN options (RFC5819: LIST-STATUS, RFC5258: LIST-EXTENDED) Possible: MESSAGES, RECENT, UIDNEXT, UIDVALIDITY, UNSEEN, MYRIGHTS, SUBSCRIBED, CHILDREN

array $select_opts

List of selection options (RFC5258: LIST-EXTENDED) Possible: SUBSCRIBED, RECURSIVEMATCH, REMOTE, SPECIAL-USE (RFC6154)

Returns

array|bool —

List of mailboxes or hash of options if STATUS/MYRIGHTS response is requested, False on error.

modFlag()

modFlag(string  $mailbox, string|array  $messages, string  $flag, string  $mod = '+') : bool

Changes flag of the message(s)

Parameters

string $mailbox

Mailbox name

string|array $messages

Message UID(s)

string $flag

Flag name

string $mod

Modifier [+|-]. Default: "+".

Returns

bool —

True on success, False on failure

r_implode()

r_implode(mixed  $element) : mixed

Joins IMAP command line elements (recursively)

Parameters

mixed $element

Returns

mixed —

clear_status_cache()

clear_status_cache(mixed  $mailbox) : mixed

Clear internal status cache

Parameters

mixed $mailbox

Returns

mixed —

clear_mailbox_cache()

clear_mailbox_cache() : mixed

Clear internal cache of the current mailbox

Returns

mixed —

flagsToStr()

flagsToStr(array  $flags) : string

Converts flags array into string for inclusion in IMAP command

Parameters

array $flags

Flags (see self::flags)

Returns

string —

Space-separated list of flags

parseCapability()

parseCapability(mixed  $str, mixed  $trusted = false) : mixed

CAPABILITY response parser

Parameters

mixed $str
mixed $trusted

Returns

mixed —

debug()

debug(string  $message) : mixed

Write the given debug text to the current debug output handler.

Parameters

string $message

Debug message text.

Returns

mixed —